//
//  Utilities.h
//  ExhibitionHall
//
//  Created by 王洋 on 2019/6/11.
//  Copyright © 2019 王洋. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@import AudioToolbox;

NS_ASSUME_NONNULL_BEGIN

@interface Utilities : NSObject


#pragma mark  View 操作 ------------------------------
+ (CGFloat)heightOfString:(NSString *)str font:(UIFont *)font width:(CGFloat)w maxHeight:(CGFloat)height;

#pragma mark  SVProgressHUD 操作 ------------------------------
/**失败信息*/
+(void)showErrorWithStatus:(NSString *)str;

/**成功信息*/
+(void)showSuccessWithStatus:(NSString *)str;

//灰色底提示语
+(void)showToast:(NSString *)msg;

//白色底提示语
+(void)showWhiteToast:(NSString *)msg;

+(void) showStatus:(NSString *)msg;

#pragma mark  微信分享压缩图片到32K ------------------------------
+ (UIImage *)TT_compressImageQualityDichotomy:(UIImage *)image toByte:(NSInteger)maxLength;
+ (NSData *)TT_compressImageQualityDichotomyData:(UIImage *)image toByte:(NSInteger)maxLength;
#pragma mark  NSTimeInterval 操作 ------------------------------
//保存数据到手机内存
+ (void)setToNSUserDefaults:(NSString *)key value:(NSString *)value;
//从手机内存中获取数据
+ (NSString *)getFromNSUserDefaults:(NSString *)key;

+ (NSString *)getDeviceIdentifier;

//获取当前时间戳
+ (NSTimeInterval )getCurrentTimestamp;
//获取服务器当前时间戳
+ (NSTimeInterval)getCurrentServerTimestamp;

+ (NSDate *)getDateWithTimestamp:(NSTimeInterval)timestamp;

+ (NSTimeInterval )getTimestampWithDate:(NSDate *)date;

+ (NSString *)getTimeFromTimestamp:(NSTimeInterval)time;

+ (NSString *)getTimeFromTimestamp:(NSTimeInterval)time AndFormater:(NSDateFormatter *)formatter;

+ (NSString *)getTodayAfterDateWithCount:(NSInteger)count;

+ (BOOL)isSameDay:(NSTimeInterval)iTime1 Time2:(NSTimeInterval)iTime2;

+ (BOOL)isBetweenFromHour:(NSInteger)fromHour toHour:(NSInteger)toHour;

+ (NSDate *)getCustomDateWithHour:(NSInteger)hour;
//检查是否有小数位
//+ (BOOL)isDoubleValueContainDecimal:(double)doubleValue;
//检查活动处于哪个阶段


#pragma mark  NSString 操作 ------------------------------

+ (NSData *)dataWithDic:(NSDictionary *)dic;

+ (NSDictionary *)dicWithData:(NSData *)jsonData;

+ (NSDictionary *)dictionaryWithJsonString:(id)jsonD;

+ (NSDictionary *)dictionaryWithString:(NSString *)jsonString;

+ (NSString *)stringWithDictionary:(NSDictionary *)dict;

+ (NSString *)changeDoubleToString:(double)doubleValue;

+ (NSString *) utf8ToUnicode:(NSString *)string;

+ (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSString *)encodStr;

+ (NSMutableDictionary *)getParams:(NSString *)str;

+ (NSMutableDictionary *)getUrlParam:(NSString *)str;

+ (NSDictionary *)convert2DictionaryWithJSONString:(NSString *)jsonString;

//检查是否包含表情
+ (BOOL)stringContainsEmoji:(NSString *)string;

//检查手机号
+ (BOOL)checkPhoneTel:(NSString *)phoneStr;

+ (BOOL)checkOnceADayWithKey:(NSString *)key;

+ (BOOL)inputShouldNumber:(NSString *)inputString;

//判断整数
+ (BOOL)isPureInt:(NSString*)string;

//判断浮点数
+ (BOOL)isPureFloat:(NSString*)string;

// 是否为邮箱地址
+ (BOOL)isEmailType;

+ (BOOL)getIsIpad;

//去除字符串的空格
+ (NSString *) GetRidOfBlankSpace:(NSString *) value;

+ (NSString *)stringToLower:(NSString *)str;

+ (NSString *)stringToUnicode:(NSString *)str;

+ (NSString *)fixHtmlStringWithUrlArray:(NSArray *)array text:(NSString *)str;


//给url拼参数
+ (NSString *)appendUrl:(NSString *)url WithValue:(NSString *)value key:(NSString *)key;

+ (float)getStringWidthWithString:(NSString *)value fontSize:(float)fontSize andHeight:(float)height;

+ (CGFloat)getStringHeightWithText:(NSString *)text font:(UIFont *)font viewWidth:(CGFloat)width;

+ (CGFloat )calculateLabelHeightWithText:(NSString *)text lineSpace:(NSInteger )lineSpace fontName:(UIFont *)fontName size:(CGSize )size label:(UILabel *)label;

+ (void)callMapWithLat:(CGFloat)latitude lng:(CGFloat)longitude AndAddress:(NSString *)address;

#pragma mark  加密 ------------------------------

+ (NSString *)base64EncodeString:(NSString *)str;
// DES加密
+ (NSString *)encodeDesWithString:(NSString *)str;
// DES解密
+ (NSString *)decodeDesWithString:(NSString *)str;
// MD5加密
+ (NSString *)md5:(NSString *)string;

+ (NSString *)NeteaseMd5:(NSString *)string;

#pragma mark  防抓包 ------------------------------
+ (BOOL)getProxyStatus;

#pragma mark  硬件Api ------------------------------
//线性马达工作（震动）
+ (void)tapticEngineWork;

+ (void)playSoundWithFileName:(NSString *)name fileType:(NSString *)type;

+ (void)callPhone:(NSString*)phoneNum;


+ (UIImage *)makeImageWithView:(UIView *)view withSize:(CGSize)size;

+ (UIImage *)imageWithColor:(UIColor *)color;

+ (UIImage *)currentViewToImage;

+ (UIViewController *)topViewController;

+ (UIViewController *)getCurrentVC;
@end

NS_ASSUME_NONNULL_END
